#!/bin/bash


#concepts
sqlite3 -header -csv stock_data.db "SELECT * FROM concepts;" > output_concepts_$(date +"%Y%m%d").csv
#stocks
sqlite3 -header -csv stock_data.db "SELECT * FROM stocks;" > output_stocks_$(date +"%Y%m%d").csv

#stock_concepts 
sqlite3 -header -csv stock_data.db "SELECT a.stock_code,c.name as stock_name,a.concept_code,b.name as concept_name,a.reason,\
a.create_time,a.delete_time,a.is_deleted \
FROM stock_concepts a \
left join concepts b on a.concept_code=b.code \
left join stocks c on a.stock_code=c.code;" \
> output_stock_concepts_$(date +"%Y%m%d").csv

#concept_stocks #top 3 stocks
sqlite3 -header -csv stock_data.db "SELECT * FROM concept_stocks;" \
> output_concept_stocks_$(date +"%Y%m%d").csv

